package org.me.bean;

import org.ksoap2.serialization.SoapObject;

import android.os.Parcel;
import android.os.Parcelable;
import android.util.Log;

public class Announcement implements Parcelable {
	private String announcementId;
	private String content;
	private String title;
	private String postedBy;
	private String postedDate;
	private String postedByName;
	private String courseScheduleId;

	public static final String Log_Tag = "announcement";
	public static Class Announcement_CLASS = new Announcement().getClass();

	public Announcement() {
	}

	public Announcement(SoapObject obj, String csId) {
		super();

		try {

			this.announcementId = obj.getPropertyAsString("announcementId");
			this.content = obj.getPropertyAsString("content");
			this.title = obj.getPropertyAsString("title");
			this.postedBy = obj.getPropertyAsString("postedBy");
			this.postedByName = obj.getPropertyAsString("postedByName");
			this.postedDate = obj.getPropertyAsString("postedDate");
			this.courseScheduleId = csId;

		} catch (Exception e) {
			Log.e(Log_Tag, e.toString());
		}

	}

	public String getAnnouncementId() {
		return announcementId;
	}

	public void setAnnouncementId(String announcementId) {
		this.announcementId = announcementId;
	}

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getPostedBy() {
		return postedBy;
	}

	public void setPostedBy(String postedBy) {
		this.postedBy = postedBy;
	}

	public void setPostedByName(String postedByName) {
		this.postedByName = postedByName;
	}

	public String getPostedByName() {
		return postedByName;
	}

	public String getPostedDate() {
		return postedDate;
	}

	public void setPostedDate(String postedDate) {
		this.postedDate = postedDate;
	}

	public String getCourseScheduleId() {
		return courseScheduleId;
	}

	public void setCourseScheduleId(String courseScheduleId) {
		this.courseScheduleId = courseScheduleId;
	}
	
	@Override
	public String toString() {
		// TODO Auto-generated method stub
		return "Title: " + title + "\n" + 
		"Post Date: " + postedDate + "\n" +
		"Post By: " + postedByName;
	}

	@Override
	public int describeContents() {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public void writeToParcel(Parcel out, int flags) {

		out.writeString(announcementId);
		out.writeString(content);
		out.writeString(title);
		out.writeString(postedBy);
		out.writeString(postedByName);
		out.writeString(postedDate);
		out.writeString(courseScheduleId);

	}

	public static final Parcelable.Creator<Announcement> CREATOR = new Parcelable
	.Creator<Announcement>() {
		public Announcement createFromParcel(Parcel in) {
			return new Announcement(in);
		}

		public Announcement[] newArray(int size) {
			return new Announcement[size];
		}
	};

	public Announcement(Parcel in) {
		readFromParcel(in);
	}

	private void readFromParcel(Parcel in) {
		announcementId = in.readString();
		content = in.readString();
		title = in.readString();
		postedBy = in.readString();
		postedByName = in.readString();
		postedDate = in.readString();
		courseScheduleId = in.readString();

	}

}
